package com.edu.hre.struts.form.leave;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.struts.action.ActionForm;
import org.apache.struts.util.LabelValueBean;

import com.edu.hre.common.utils.BeanFinder;
import com.edu.hre.common.utils.CommonUtils;
import com.edu.hre.db.pojo.HreLeaveType;
import com.edu.hre.db.service.BaseService;
import com.edu.hre.struts.action.leave.LeaveRequestUpdateAction;

public class LeaveRequestUpdateForm extends ActionForm {

	/**
	 * 
	 */
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
	private static final long serialVersionUID = -8483852353127690666L;

	private Integer id;
	private int empNum;
	private Date firstLeave;
	private Date lastLeave;
	private int supervisorNum;
	private String supervisorFullName;
	private Boolean approved;
	private int leaveTypeId;
	private String leaveTypeName;
	private Date dateCreated;
	private Date dateModified;
	private String empComment;
	private String firstTimeValue;
	private String lastTimeValue; 
	private List<LabelValueBean> listFirstTime = new ArrayList<LabelValueBean>();
	private List<LabelValueBean> listLastTime = new ArrayList<LabelValueBean>();
	private List<HreLeaveType> leaveTypeList = new ArrayList<HreLeaveType>();
	private List<LabelValueBean> supervisorList = new ArrayList<LabelValueBean>();

	private boolean isSelected = false;
	private String message = "";
	private boolean isAddNew = true;

	public LeaveRequestUpdateForm() {
	}

	public LeaveRequestUpdateForm(int empNum, Date firstLeave, Date lastLeave, int supervisorNum, int leaveTypeId) {
		this.empNum = empNum;
		this.firstLeave = firstLeave;
		this.lastLeave = lastLeave;
		this.supervisorNum = supervisorNum;
		this.leaveTypeId = leaveTypeId;
	}

	public LeaveRequestUpdateForm(Integer id, int empNum, Date firstLeave, Date lastLeave, int supervisorNum,
			Boolean approved, int leaveTypeId, Date dateCreated, Date dateModified, String empComment, String supComment) {
		this.id = id;
		this.empNum = empNum;
		this.firstLeave = firstLeave;
		this.lastLeave = lastLeave;
		this.supervisorNum = supervisorNum;
		this.approved = approved;
		this.leaveTypeId = leaveTypeId;
		this.dateCreated = dateCreated;
		this.dateModified = dateModified;
		this.setEmpComment(empComment);
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getEmpNum() {
		return this.empNum;
	}

	public void setEmpNum(int empNum) {
		this.empNum = empNum;
	}

	public Date getFirstLeave() {
		return this.firstLeave;
	}

	public void setFirstLeave(Date firstLeave) {
		this.firstLeave = firstLeave;
	}

	public String getFirstLeaveStr() {
		if (this.firstLeave == null) {
			return "";
		}
		return dateFormat.format(this.firstLeave);
	}

	public void setFirstLeaveStr(String firstLeave) {
		try {
			this.firstLeave = dateFormat.parse(firstLeave);
		} catch (Exception e) {
			CommonUtils.println(e.getMessage());
		}
	}

	public Date getLastLeave() {
		return this.lastLeave;
	}

	public void setLastLeave(Date lastLeave) {
		this.lastLeave = lastLeave;
	}

	public String getLastLeaveStr() {
		if (this.lastLeave == null) {
			return "";
		}
		return dateFormat.format(this.lastLeave);
	}

	public void setLastLeaveStr(String lastLeave) {
		try {
			this.lastLeave = dateFormat.parse(lastLeave);
		} catch (Exception e) {
		}
	}

	public int getSupervisorNum() {
		return this.supervisorNum;
	}

	public void setSupervisorNum(int supervisorNum) {
		this.supervisorNum = supervisorNum;
	}

	public Boolean getApproved() {
		return this.approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public int getLeaveTypeId() {
		return this.leaveTypeId;
	}

	public void setLeaveTypeId(int leaveTypeId) {
		this.leaveTypeId = leaveTypeId;
	}

	public Date getDateCreated() {
		return this.dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateModified() {
		return this.dateModified;
	}

	public void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public boolean getIsSelected() {
		return isSelected;
	}

	public void setIsSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isAddNew() {
		return isAddNew;
	}

	public void setAddNew(boolean isAddNew) {
		this.isAddNew = isAddNew;
	}

	public boolean getIsAddNew() {
		return isAddNew;
	}

	public void setIsAddNew(boolean isAddNew) {
		this.isAddNew = isAddNew;
	}

	public String getSupervisorFullName() {
		return supervisorFullName;
	}

	public void setSupervisorFullName(String supervisorFullName) {
		this.supervisorFullName = supervisorFullName;
	}

	public String getLeaveTypeName() {
		return leaveTypeName;
	}

	public void setLeaveTypeName(String leaveTypeName) {
		this.leaveTypeName = leaveTypeName;
	}

	public List<LabelValueBean> getSupervisorList() {
		return supervisorList;
	}

	public void setSupervisorList(List<LabelValueBean> supervisorList) {
		this.supervisorList = supervisorList;
	}

	public List<HreLeaveType> getLeaveTypeList() {
		return leaveTypeList;
	}

	public void setLeaveTypeList(List<HreLeaveType> leaveTypeList) {
		this.leaveTypeList = leaveTypeList;
	}

	public String getFirstTimeValue() {
		return firstTimeValue;
	}

	public void setFirstTimeValue(String firstTimeValue) {
		this.firstTimeValue = firstTimeValue;
	}

	public String getLastTimeValue() {
		return lastTimeValue;
	}

	public void setLastTimeValue(String lastTimeValue) {
		this.lastTimeValue = lastTimeValue;
	}

	public List<LabelValueBean> getListFirstTime() {
		return listFirstTime;
	}

	public void setListFirstTime(List<LabelValueBean> listFirstTime) {
		this.listFirstTime = listFirstTime;
	}

	public List<LabelValueBean> getListLastTime() {
		return listLastTime;
	}

	public void setListLastTime(List<LabelValueBean> listLastTime) {
		this.listLastTime = listLastTime;
	}

	public String getTotalPaidLeaved() {
		float totalPaidLeavedDays = LeaveRequestUpdateAction.getTotalPaidLeavedDays(empNum);
		float totalGrantPaidLeave = LeaveRequestUpdateAction.getTotalGrantedLeaveDays(empNum);
		String tmp = totalPaidLeavedDays + "/" + totalGrantPaidLeave;
		CommonUtils.println("getTotalPaidLeaved: " + tmp);
		return tmp;
	}

	public float getTotalOtherLeaved() {
		return LeaveRequestUpdateAction.getTotalOtherLeavedDays(empNum);
	}

	public String getEmpComment() {
		return empComment;
	}

	public void setEmpComment(String empComment) {
		this.empComment = empComment;
	}

	 
}
